import java.util.*;
//Treeset是有序的
// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class code2 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int m = in.nextInt();
        TreeSet<Integer> set = new TreeSet<>();
        int x;
        while(n--!=0) {
            x = in.nextInt();
            set.add(x);
        }
        while(m--!=0) {
            x = in.nextInt();
            set.add(x);
        }
        for(int a:set) {
            System.out.print(a+" ");
        }
    }
}